package com.twu.biblioteca;

import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.Map;

public class Books {

    private HashMap<String,Boolean> books = new HashMap<String,Boolean>();

    public Books()
    {
        books.put("PelicanBrief", true);
        books.put("Da Vinci Code", true);
        books.put("Angels n Demons", false);
        books.put("The Immortals of Meluha", true);
        books.put("The Secret of Nagas", true);
        books.put("The Oath of Vayuputras", true);
        books.put("Stay Hungry Stay Foolish", true);
    }

    public HashMap<String, Boolean> getBooks() {
        return books;
    }

    public void addBooks(String name)
    {
        books.put(name, true);
    }

    public void displayBooks()
    {
        Map<String, Boolean> map = books;
        System.out.println("The list of books is:\n");
        for (Map.Entry<String, Boolean> entry : map.entrySet()) {
            System.out.println(entry.getKey());
        }
    }

    public Boolean checkAvailabilityOfBook(String name)
    {
        if(books.get(name))
        {
            return true;
        }
        return false;
    }

    public Boolean reserveBook(String name)
    {
        if(checkAvailabilityOfBook(name))
        {
            books.put(name, false);
            return true;
        }
        return false;
    }
}
